package com.ygqh.baby.utils;

import com.ygqh.baby.exception.YgException;
import com.ygqh.baby.po.YgUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

public class SessionUtil {
    public static YgUser getCurrentUser() {
        Subject subject = SecurityUtils.getSubject();
        if (subject.isAuthenticated()) {
            YgUser user = (YgUser) subject.getPrincipal();
            return user;
        }
        throw new YgException("002", "REDIRECT_LONGIN_PAGE");
    }
}
